---
title: "Race Analysis"
date: "2022-12-07"
output: 
  pdf_document: default
  html_document: default
header-includes:
  - \usepackage[labelformat = empty]{caption}
  - \usepackage[textfont = bf]{caption}
fig_width: 3
fig_height: 2
urlcolor: blue
---

```{r Setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(haven)
library(fixest)
library(plyr)
library(dplyr)
library(tidyverse)
library(modelsummary)
library(kableExtra)
library(stargazer)
library(fedmatch)
library(data.table)
setwd("/Users/kiranmisra/Desktop/Replication Paper")
```

```{r Data, include=FALSE}
regdata <- read_dta("MainRegressions.dta") 
racedata <-read_csv("gov_2001_data.csv")
colnames(regdata)[10] <- "respondent_race"

racedata <- racedata %>%
  mutate(rep_name = paste(FirstName, LastName, sep = " "))

regdata$ID <- seq.int(nrow(regdata))

fuzzy_merge <- merge_plus(data1 = regdata,
                          data2 = racedata,
                          by.x = 'rep_current',
                          by.y = 'rep_name',
                          match_type = 'fuzzy',
                          unique_key_1 = 'ID',
                          unique_key_2 = 'FullIndex')

merged_data <- fuzzy_merge$matches

merged_data %>% select(approval_rep,
                approval,
                weight_cumulative,
                voted_for_inc,
                votematchmean2,
                female,
                dem,
                cong,
                copartisan,
                majority,
                chair,
                seniority,
                power,
                dist_id,
                dist_id2,
                icpsr,
                gender_respondent,
                respondent_race,
                votematchmean_womens,
                votematchmean_mens,
                Race)-> data
colnames(data)[21] <- "race"

# Representative Race
data$rep_white <- "0"
data$rep_white[data$race==0] <- "1"

data$rep_black <- "0"
data$rep_black[data$race==1] <- "1"

data$rep_hispanic <- "0"
data$rep_hispanic[data$race==2] <- "1"

data$rep_asian <- "0"
data$rep_asian[data$race==3] <- "1"

data$rep_native <- "0"
data$rep_native[data$race==4] <- "1"

#Constituent Race
data$cons_white <- "0"
data$cons_white[data$respondent_race==1] <- "1"

data$cons_black <- "0"
data$cons_black[data$respondent_race==2] <- "1"

data$cons_hispanic <- "0"
data$cons_hispanic[data$respondent_race==3] <- "1"

data$cons_asian <- "0"
data$cons_asian[data$respondent_race==4] <- "1"

data$cons_native <- "0"
data$cons_native[data$respondent_race==5] <- "1"

data$cons_middleeastern <- "0"
data$cons_middleeastern[data$respondent_race==8] <- "1"

data$cons_multiple <- "0"
data$cons_multiple[data$respondent_race==6] <- "1"

data$cons_other <- "0"
data$cons_other[data$respondent_race==7] <- "1"

data_subset_rrace <- lapply(1:8, function(x){
  data %>%
    filter(respondent_race == x)
  })

```

```{r Summary Statistics, echo=FALSE}

# Summarize weighted approval
data %>%
  summarize(w_approval = weighted.mean(approval, 
                                       w = weight_cumulative, 
                                       na.rm = TRUE))

# Summarize weighted voted for incumbent
data %>%
  summarize(w_vote4inc = weighted.mean(voted_for_inc, 
                                       w = weight_cumulative, 
                                       na.rm = TRUE))

# Create weighted mean for policy agreement
data %>%
  summarize(w_votematchmean2 = weighted.mean(votematchmean2, 
                                             w = weight_cumulative, 
                                             na.rm = TRUE))

# Create weighted means by female legislators
data %>%
  group_by(female) %>%
  summarize(w_mean_sex = weighted.mean(votematchmean2, 
                                       w = weight_cumulative, 
                                       na.rm = TRUE))

# Create weighted means by race
data %>%
  group_by(race) %>%
  summarize(w_mean_race = weighted.mean(votematchmean2, 
                                       w = weight_cumulative, 
                                       na.rm = TRUE)) -> w_mean_race

# Create tab of proportion of policy agreement
data %>% 
  count(votematchmean2, wt = weight_cumulative) %>%
  mutate(prop = n/sum(n))

#Summarize racial proportion of representatives
length(unique(data$icpsr))

#Summary statistics
data$race_tab[data$race == 0] <- "White"
data$race_tab[data$race == 1] <- "Black"
data$race_tab[data$race == 2] <- "Hispanic"
data$race_tab[data$race == 3] <- "Asian"
data$race_tab[data$race == 4] <- "Native American"
racesumtab1 <- kable(table(data$race_tab), col.names = c("Member Race","# of Respondents"))
print(racesumtab1)

data$female_tab[data$female == 0] <- "Man"
data$female_tab[data$female == 1] <- "Woman"
gendersumtab1 <- kable(table(data$female_tab), col.names = c("Member Gender", "# of Respondents"))
print(gendersumtab1)

blackmoc <- table(unique(merged_data$rep_name[merged_data$Race == 1]))
hispmoc <- table(unique(merged_data$rep_name[merged_data$Race == 2]))
asianmoc <- table(unique(merged_data$rep_name[merged_data$Race == 3]))
```

```{r Approval Regressions, echo=FALSE}

# Approval (Gender) (Original)
approvalmod1 <- feols(approval ~ factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong) 
                     | dist_id, 
                     data = data, 
                     vcov_cluster(~icpsr),
                     weights = ~weight_cumulative)

# Approval (White)
approvalmod2 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Black)
approvalmod3 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Hispanic)
approvalmod4 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Asian)
approvalmod5 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#Approval with Gender and Race Interacted (White)
approvalmod6 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_white) * factor(female) + factor(rep_white) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#Approval with Gender and Race Interacted (Black)
approvalmod7 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_black) * factor(female) + factor(rep_black) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#Approval with Gender and Race Interacted (Hispanic)
approvalmod8 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_hispanic) * factor(female) + factor(rep_hispanic) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#Approval with Gender and Race Interacted (Asian)
approvalmod9 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_asian) * factor(female) + factor(rep_asian) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)
```

```{r Vote Choice Regressions, echo=FALSE}

# Vote Choice (Gender) (Original)
votechoicemod1 <- feols(voted_for_inc ~ factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (White)
votechoicemod2 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Black)
votechoicemod3 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Hispanic)
votechoicemod4 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Asian)
votechoicemod5 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice with Gender and Race Interacted (White)
votechoicemod6 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_white) * factor(female) + factor(rep_white) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice with Gender and Race Interacted (Black)
votechoicemod7 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_black) * factor(female) + factor(rep_black) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice with Gender and Race Interacted (Hispanic)
votechoicemod8 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_hispanic) * factor(female) + factor(rep_hispanic) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice with Gender and Race Interacted (Asian)
votechoicemod9 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + factor(rep_asian) * factor(female) + factor(rep_asian) * factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data, 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)
```

```{r Approval Tables, echo=FALSE}

## Create Table 1
models_approval <- list("White" = approvalmod2, "Black" = approvalmod3, "Hispanic" = approvalmod4, "Asian" = approvalmod5)

row_names <- c("factor(rep_white)1" = "Member is White","factor(rep_black)1" = "Member is Black","factor(rep_hispanic)1" = "Member is Hispanic","factor(rep_asian)1" = "Member is Asian","votematchmean2" = "Policy Disagreement", "factor(rep_white)1:votematchmean2" = "Member is White + Policy Disagreement", "factor(rep_black)1:votematchmean2" = "Member is Black + Policy Disagreement", "factor(rep_hispanic)1:votematchmean2" = "Member is Hispanic + Policy Disagreement", "factor(rep_asian)1:votematchmean2" = "Member is Asian + Policy Disagreement")

row_order <- c("factor(rep_white)1" = "Member is White","factor(rep_black)1" = "Member is Black","factor(rep_hispanic)1" = "Member is Hispanic","factor(rep_asian)1" = "Member is Asian","votematchmean2" = "Policy Disagreement", "factor(rep_white)1:votematchmean2" = "Member is White + Policy Disagreement", "factor(rep_black)1:votematchmean2" = "Member is Black + Policy Disagreement", "factor(rep_hispanic)1:votematchmean2" = "Member is Hispanic + Policy Disagreement", "factor(rep_asian)1:votematchmean2" = "Member is Asian + Policy Disagreement")

rows <- tribble(~term, ~White, ~Black, ~Hispanic, ~Asian,
                'District fixed-effects', 'Yes', 'Yes', 'Yes', 'Yes',
                'Party-year fixed-effects', 'Yes', 'Yes', 'Yes', 'Yes',
                'Controls', 'Yes', 'Yes', 'Yes', 'Yes')

Table1 <- modelsummary(models_approval, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Constituent Approval',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table1 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Vote Choice Tables, echo=FALSE}

## Create Table 3
models_votechoice <- list("White" = votechoicemod2, "Black" = votechoicemod3, "Hispanic" = votechoicemod4, "Asian" = votechoicemod5)

Table3 <- modelsummary(models_votechoice, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Constituent Vote Choice',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table3 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Approval by Race Regressions, echo=FALSE}

##############################
######White Constituents######
##############################

# Approval (White Constituents for White Representatives)
approvalracemod1 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (White Constituents for Black Representatives)
approvalracemod2 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (White Constituents for Hispanic Representatives)
approvalracemod3 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (White Constituents for Asian Representatives)
approvalracemod4 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

##############################
######Black Constituents######
##############################

# Approval (Black Constituents for White Representatives)
approvalracemod5 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Black Constituents for Black Representatives)
approvalracemod6 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Black Constituents for Hispanic Representatives)
approvalracemod7 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Black Constituents for Asian Representatives)
approvalracemod8 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#############################
####Hispanic Constituents####
#############################

# Approval (Hispanic Constituents for White Representatives)
approvalracemod9 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Hispanic Constituents for Black Representatives)
approvalracemod10 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Hispanic Constituents for Hispanic Representatives)
approvalracemod11 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Hispanic Constituents for Asian Representatives)
approvalracemod12 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

############################
#####Asian Constituents#####
############################

# Approval (Asian Constituents for White Representatives)
approvalracemod13 <- feols(approval ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Asian Constituents for Black Representatives)
approvalracemod14 <- feols(approval ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Asian Constituents for Hispanic Representatives)
approvalracemod15 <- feols(approval ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Approval (Asian Constituents for Asian Representatives)
approvalracemod16 <- feols(approval ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)
```

```{r Approval for White Constituents, echo=FALSE}

models_approval_whitevoters <- list("White Representative" = approvalracemod1, "Black Representative" = approvalracemod2, "Hispanic Representative" = approvalracemod3, "Asian Representative" = approvalracemod4)

Table5 <- modelsummary(models_approval_whitevoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and White Approval',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table5 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Approval for Black Constituents, echo=FALSE}

models_approval_blackvoters <- list("White Representative" = approvalracemod5, "Black Representative" = approvalracemod6, "Hispanic Representative" = approvalracemod7, "Asian Representative" = approvalracemod8)

Table6 <- modelsummary(models_approval_blackvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Black Approval',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table6 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Approval for Hispanic Constituents, echo=FALSE}

models_approval_hispanicvoters <- list("White Representative" = approvalracemod9, "Black Representative" = approvalracemod10, "Hispanic Representative" = approvalracemod11, "Asian Representative" = approvalracemod12)

Table7 <- modelsummary(models_approval_hispanicvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Hispanic Approval',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table7 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Approval for Asian Constituents, echo=FALSE}

models_approval_asianvoters <- list("White Representative" = approvalracemod13, "Black Representative" = approvalracemod14, "Hispanic Representative" = approvalracemod15, "Asian Representative" = approvalracemod16)

Table8 <- modelsummary(models_approval_asianvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Asian Approval',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table8 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Vote Choice by Race Regressions, echo=FALSE}

##############################
######White Constituents######
##############################

# Vote Choice (White Constituents for White Representatives)
votechoiceracemod1 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (White Constituents for Black Representatives)
votechoiceracemod2 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (White Constituents for Hispanic Representatives)
votechoiceracemod3 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (White Constituents for Asian Representatives)
votechoiceracemod4 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[1]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

##############################
######Black Constituents######
##############################

# Vote Choice (Black Constituents for White Representatives)
votechoiceracemod5 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Black Constituents for Black Representatives)
votechoiceracemod6 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Black Constituents for Hispanic Representatives)
votechoiceracemod7 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Black Constituents for Asian Representatives)
votechoiceracemod8 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[2]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

#############################
####Hispanic Constituents####
#############################

# Vote Choice (Hispanic Constituents for White Representatives)
votechoiceracemod9 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Hispanic Constituents for Black Representatives)
votechoiceracemod10 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Hispanic Constituents for Hispanic Representatives)
votechoiceracemod11 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Hispanic Constituents for Asian Representatives)
votechoiceracemod12 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[3]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

############################
#####Asian Constituents#####
############################

# Vote Choice (Asian Constituents for White Representatives)
votechoiceracemod13 <- feols(voted_for_inc ~ factor(rep_white) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_white) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Asian Constituents for Black Representatives)
votechoiceracemod14 <- feols(voted_for_inc ~ factor(rep_black) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_black) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Asian Constituents for Hispanic Representatives)
votechoiceracemod15 <- feols(voted_for_inc ~ factor(rep_hispanic) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_hispanic) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)

# Vote Choice (Asian Constituents for Asian Representatives)
votechoiceracemod16 <- feols(voted_for_inc ~ factor(rep_asian) + factor(dem) + votematchmean2 + factor(female) + factor(cong) + factor(rep_asian) * votematchmean2 + factor(female) * votematchmean2 + copartisan + majority + chair + seniority + power + factor(dem) * factor(cong)
                      | dist_id, 
                      data = data_subset_rrace[[4]], 
                      vcov_cluster(~icpsr),
                      weights = ~weight_cumulative)
```


```{r Vote Choice for White Constituents, echo=FALSE}

## Create Table
models_votechoice_whitevoters <- list("White Representative" = votechoiceracemod1, "Black Representative" = votechoiceracemod2, "Hispanic Representative" = votechoiceracemod3, "Asian Representative" = votechoiceracemod4)

Table9 <- modelsummary(models_votechoice_whitevoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and White Vote Choice',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table9 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Vote Choice for Black Constituents, echo=FALSE}

models_votechoice_blackvoters <- list("White Representative" = votechoiceracemod5, "Black Representative" = votechoiceracemod6, "Hispanic Representative" = votechoiceracemod7, "Asian Representative" = votechoiceracemod8)

Table10 <- modelsummary(models_votechoice_blackvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Black Vote Choice',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table10 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Vote Choice for Hispanic Constituents, echo=FALSE}

models_votechoice_hispanicvoters <- list("White Representative" = votechoiceracemod9, "Black Representative" = votechoiceracemod10, "Hispanic Representative" = votechoiceracemod11, "Asian Representative" = votechoiceracemod12)

Table11 <- modelsummary(models_votechoice_hispanicvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Hispanic Vote Choice',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table11 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```

```{r Vote Choice for Asian Constituents, echo=FALSE}

models_votechoice_asianvoters <- list("White Representative" = votechoiceracemod13, "Black Representative" = votechoiceracemod14, "Hispanic Representative" = votechoiceracemod15, "Asian Representative" = votechoiceracemod16)

Table12 <- modelsummary(models_votechoice_asianvoters, 
             coef_map = row_order, 
             stars = c('*' = .1, '**' = .05),
             gof_map = c("nobs"),
             title = 'The Relationship Between Legislative Behavior and Asian Vote Choice',
             add_rows = rows,
             output = "kableExtra",
             threeparttable = TRUE)

Table12 %>% 
  kable_styling(latex_options = c("scale_down", "striped"))
```
